let favorate = document.querySelector(".favorate");
let ul = favorate.querySelector("ul");
let content = document.querySelector(".content")
// console.log(ul);
// console.log(favorate);

let xhr = new XMLHttpRequest();
xhr.open(
    "get",
    `/my/movie/v1/list/wish/order/coming.json?ci=20&limit=30&offset=0`
);
xhr.send();
xhr.onload = function () {
    let res = JSON.parse(xhr.responseText);
    // console.log(res.data.coming)
    render(res.data.coming)
};

function render(data) {
    let str = ""
    data.forEach(item => {
        // console.log(item);
        str += `<li>
        <img src="${item.img.replace("w.h/","")}" alt="">
        <p>${item.nm}</p>
        <div>${item.wish}人想看</div>
        <span>${item.rt}</span>
    </li>`
    })
    ul.innerHTML = str;
}

let xhr2 = new XMLHttpRequest();
xhr2.open(
    "get",
    `/my/movie/v2/list/rt/order/coming.json?ci=20&limit=10`
);
xhr2.send();
xhr2.onload = function () {
    let res2 = JSON.parse(xhr2.responseText)
    // console.log(res2.data.coming);
    render2(res2.data.coming)
};

function render2(data) {
    let str = "";
    data.forEach(item => {
        console.log(item);
        str += `<div class="main-block">
        <div class="imgBox"><img src="${item.img.replace("w.h/","")}" alt=""></div>
        <div class="recommend">
            <div>
                <div>${item.nm}</div>
                <span>${item.cat}</span>
                <div>${item.desc}</div>
                <div>${item.showInfo}</div>
            </div>
            <div>
                <p><i>${item.wish}</i>人想看</p>
                <span>想看</span>
            </div>
        </div>
    </div>`
    });
    content.innerHTML = str;
}